package vn.conghuy.talkwithme.data.livescore;


public class LivescoreEvent {
	
	public static final int WT_HOME = 0;
	public static final int WT_AWAY = 1;
	
	public static final int ET_NONE = -1;
	public static final int ET_GOAL = 0;
	public static final int ET_YELLOW = 1;
	public static final int ET_RED = 2;
	public static final int ET_NO_GOAL = 3;
	
	public int time;
	public int homeType;
	public int awayType;
	public String homePlayer;
	public String awayPlayer;
	public int currentHomeScore;
	public int currentAwayScore;
	
	private LivescoreMatch match;
	
	public LivescoreEvent(LivescoreMatch match) {
		setMatch(match);
		homeType = awayType = ET_NONE;
	}
	
	public void setMatch(LivescoreMatch match){
		this.match = match;
	}
	
	@Override
	public String toString() {
		StringBuilder strBuilder = new StringBuilder();
		strBuilder.append(time).append("' : ");
		if(homeType == ET_GOAL || awayType == ET_GOAL){
			strBuilder.append(currentHomeScore).append(" - ").append(currentAwayScore).append(", ");
		}
		if(homeType != ET_NONE ){
			if(homePlayer.equals("") == false) strBuilder.append(homePlayer).append(" : ");
			strBuilder.append("(").append(match.home).append(")");
			strBuilder.append(", ");
			strBuilder.append(typeString(homeType));
		}
		if(awayType != ET_NONE){
			if(awayPlayer.equals("") == false) strBuilder.append(awayPlayer).append(" : ");
			strBuilder.append("(").append(match.away).append(")");
			strBuilder.append(", ");
			strBuilder.append(typeString(awayType));
		}
		return strBuilder.toString();
	}
	
	private String typeString(int type){
		switch (type) {
		case ET_GOAL:
			return "goal";
		case ET_NO_GOAL:
			return "miss penalty";
		case ET_YELLOW:
			return "yellow card";
		case ET_RED:
			return "red card";
		default:
			return null;
		}
	}

}
